var app = getApp();

Page({
    data: {
        test_ticket: !1
    },
    onLoad: function(t) {
        wx.hideShareMenu();
        this.setData({
            id: t.id,
            state: t.state,
            states: t.states,
            fu_id: t.fu_id
        });
    },
    refresh: function(t) {
        var a = this, e = a.data.id, i = a.data.fu_id;
        app.util.request({
            url: "entry/wxapp/PjDetails",
            cachetime: "0",
            data: {
                ticket_id: e
            },
            success: function(t) {
                console.log(t), t.data.pjdetails.end_time = app.ormatDate(t.data.pjdetails.end_time).slice(0, 16), 
                t.data.pjdetails.start_time = app.ormatDate(t.data.pjdetails.start_time).slice(0, 16), 
                a.setData({
                    details: t.data.pjdetails,
                    bminfo: t.data.bminfo
                });
            }
        }), console.log(e), console.log(i), app.util.request({
            url: "entry/wxapp/PjCode",
            cachetime: "0",
            data: {
                ticket_id: e,
                fu_id: i
            },
            success: function(t) {
                console.log(t), a.setData({
                    bath: t.data
                });
            }
        });
    },
    yaoqing: function() {
        wx.navigateTo({
            url: "../../yaoqing/yaoqing"
        });
    },
    test_ticket: function(t) {
        var a = this, e = a.data.test_ticket;
        0 == e ? a.setData({
            test_ticket: !0
        }) : a.setData({
            test_ticket: !1
        });
    },
    hx_code: function(t) {
        var a = t.detail.value;
        this.setData({
            value: a
        });
    },
    Determine: function(t) {
        var a = this.data.details, e = this.data.value;
        wx.getStorageSync("userInfo").id;
        app.util.request({
            url: "entry/wxapp/ManualHx",
            data: {
                ticket_id: a.id,
                hx_code: e
            },
            success: function(t) {
                console.log(t), 1 == t.data ? (wx.showToast({
                    title: "核销成功"
                }), setTimeout(function() {
                    wx.navigateBack({
                        delta: 1
                    });
                }, 1500)) : wx.showToast({
                    title: "核销码错误"
                });
            }
        });
    },
    apply: function(t) {
        var a = this.data.details;
        if (0 == a.money) var e = 5; else e = 4;
        var i = app.today_time();
        console.log(i), wx.showModal({
            title: "",
            content: "是否要退票",
            success: function(t) {
                t.confirm ? (console.log("用户点击确定"), i >= a.start_time ? wx.showModal({
                    title: "",
                    content: "活动已经开始，无法退票"
                }) : app.util.request({
                    url: "entry/wxapp/ApplyRefund",
                    data: {
                        ticket_id: a.id,
                        state: e
                    },
                    success: function(t) {
                        console.log(t), wx.showToast({
                            title: "申请成功"
                        }), setTimeout(function() {
                            wx.navigateBack({
                                delta: 1
                            });
                        }, 1500);
                    }
                })) : t.cancel && console.log("用户点击取消");
            }
        });
    },
    onReady: function() {},
    onShow: function() {
        this.refresh();
    },
    onHide: function() {},
    onUnload: function() {},
    onPullDownRefresh: function() {
        this.refresh();
    },
    onReachBottom: function() {}
});